import std.stdio;
import std.conv;

alias CBACK = void delegate();

class A(T)
{
    alias CallBack  = void delegate(T a, ulong size);
    void show(D : CallBack)(T a, D b) if (is(D == delegate))
    {
        writeln("show(D) ", a, "   D is :" ,to!string(b));
    }
    
    void show(T a)
    {
        show!(CallBack)(a,null);
    }
    
    void showT(T a)
    {
        writeln("showT ", a);
    }
    
    T a;
}


class   B (IN,OUT)
{

    alias CALLBACK = void delegate(OUT ou, ulong size);
    void read(IN i){}
    
    void write(OUT ou, CALLBACK cb = null)
    {
        writeln("out  ==  ", out);
        if(cb)
            cb(ou,0);
    }
}


void show(T,D)(T a, D b)if (is(D == delegate))
{
    writeln("show(D) ", a, "   D is :" ,to!string(b));
}

void show(T)(T a)
{
    show!(T,CBACK)(a,null);
}

void main()
{
    auto a = new A!int();
    a.a = 10;
    a.show(20,delegate(int ){});
    a.show(20);
    a.showT(10);
    show(10);
    show(10,delegate(){});
}
